﻿using UnityEngine;
using System.Collections;

public class Twitter : MonoBehaviour {
	// Use this for initialization
	void Start () {
		
	}
	
	
	// Update is called once per frame
	void Update () {
		
		//タッチ検出処理
		if(Input.touchCount == 1){
			
			Vector2 tapPoint = Camera.main.ScreenToWorldPoint (Input.mousePosition);
			Collider2D col = Physics2D.OverlapPoint (tapPoint);
			if (col == this.collider2D) {
				// WebブラウザのTwitter投稿画面を開く
				Application.OpenURL("http://twitter.com/intent/tweet?text=" + WWW.EscapeURL("テキスト #hashtag"));
			}

		}
		
		//マウス検出処理（デバッグ用）
		if (Input.GetMouseButtonDown (0)) {

			Vector2 tapPoint = Camera.main.ScreenToWorldPoint (Input.mousePosition);
			Collider2D col = Physics2D.OverlapPoint (tapPoint);
			if (col == this.collider2D) {
				// WebブラウザのTwitter投稿画面を開く
				Application.OpenURL("http://twitter.com/intent/tweet?text=" + WWW.EscapeURL("テキスト #hashtag"));
			}

		}

	}
}
